import varsFactory, { getVarsInstance } from '@/common/varsFactory'
export const vars = varsFactory('main', {}, { '!TESTSUITE_LOOP': 1 })
import store from '@/store';
import { setVariables } from '@/actions'
// 监听变量改变
export const bindVariableChange = () => {
    // Note: bind to onChange in next tick, to make sure vars instance is already initialized
    // so that `bindVariableChange` could be executed before `initPlayer`
    setTimeout(() => {
        getVarsInstance().onChange(({ vars }: any) => {
            const variables = Object.keys(vars).map((key) => ({ key, value: vars[key] }));
            store.dispatch(setVariables(variables));
        });
    }, 0);
};